package view;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.layout.HorizontalLayout;
import org.uqbar.arena.layout.VerticalLayout;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.windows.SimpleWindow;
import org.uqbar.arena.windows.Window;
import org.uqbar.arena.windows.WindowOwner;

import asiento.Asiento;

public abstract class InformeWindow<Asiento> extends Window {
	
	private String tipoDeOperacionRealizada;


	public InformeWindow(WindowOwner parent, Asiento model, String tipoDeOperacionRealizada) {
		super(parent, model);
		this.setTipoDeOperacionRealizada(tipoDeOperacionRealizada);
	}


	public void createContents(Panel mainPanel) {
		this.setTitle("Aterrizar.com");
		mainPanel.setLayout(new VerticalLayout());
		this.createFormPanel(mainPanel);
		this.createActionsPanel(mainPanel);

	}
	
	
	protected void createFormPanel(Panel mainPanel) {
		
		new Label(mainPanel).setText(this.armarTexto());

	}
	
	protected void addActions(Panel actionsPanel) {
		this.agregarBotones(actionsPanel);
		
		new Button(actionsPanel)//
		.setCaption(this.getButtonName())
		.onClick(new MessageSend(this.getOwner(), "limpiar"))
		.onClick(new MessageSend(this, "close"));
		

	}
	protected void createActionsPanel(Panel mainPanel) {
		Panel actionsPanel = new Panel(mainPanel);
		actionsPanel.setLayout(new HorizontalLayout());
		this.addActions(actionsPanel);
	}

	public void agregarBotones(Panel actionsPanel) {
		//por defecto: no se agregan mas botones
	}

	public abstract String getButtonName();

	public abstract String armarTexto();

	public void setTipoDeOperacionRealizada(String tipoDeOperacionRealizada) {
		this.tipoDeOperacionRealizada = tipoDeOperacionRealizada;
	}

	public String getTipoDeOperacionRealizada() {
		return tipoDeOperacionRealizada;
	}

}
